package com.kaishengit.pojo;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.kaishengit.util.DateUtil;

@Entity
@Table(name="t_project")
public class Project {
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private int id;
	private String projectname;
	private String createtime;
	
	@ManyToMany
	@JoinTable(name="t_project_user",joinColumns=@JoinColumn(name="projectid"),inverseJoinColumns=@JoinColumn(name="userid"))
	private List<User> users;
	
	@OneToMany(mappedBy="project",cascade=CascadeType.PERSIST)
	private List<Document> documents;
	
	@OneToMany(mappedBy="project",cascade=CascadeType.PERSIST)
	private List<Milestone> milestones;
	
	@OneToMany(mappedBy="project",cascade=CascadeType.PERSIST)
	private List<Issues> issues;
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getProjectname() {
		return projectname;
	}
	public void setProjectname(String projectname) {
		this.projectname = projectname;
	}
	public String getCreatetime() {
		return DateUtil.friendlyTime(DateUtil.stringToDate(createtime));
	}
	public void setCreatetime(String createtime) {
		this.createtime = createtime;
	}
	public List<User> getUsers() {
		return users;
	}
	public void setUsers(List<User> users) {
		this.users = users;
	}
	public void setDocuments(List<Document> documents) {
		this.documents = documents;
	}
	public List<Document> getDocuments() {
		return documents;
	}
	public void setMilestones(List<Milestone> milestones) {
		this.milestones = milestones;
	}
	public List<Milestone> getMilestones() {
		return milestones;
	}
	public void setIssues(List<Issues> issues) {
		this.issues = issues;
	}
	public List<Issues> getIssues() {
		return issues;
	}
	
}
